π fix: silence the credential helper's audit-log append and pre-create the log so it records - #6106
Conversation
β¦e the log so it records Every agent clone, fetch, and push printed git-credential-hive.sh: line 157: /var/run/hive-metrics/token-access.jsonl: Permission denied into the agent's pane. The helper appends an audit line with `>> "$LOG" 2>/dev/null || true`, but `2>/dev/null` only mutes the printf: when the redirection itself fails the shell reports it on its own stderr before the command runs. gh-wrapper.sh had this exact bug and fixed it by wrapping the append in a group (hivecommons#4043); the credential helper never got the same treatment. The redirection always failed on a per-UID hive: /var/run/hive-metrics is 0755 dev:node by design (hivecommons#4044, protecting the bot-identity file under agent-tokens/) and nothing ever created token-access.jsonl, so no agent UID could open it. That also means the audit log both writers feed β and GET /api/token-access reads β has been empty on every per-UID hive. - bin/git-credential-hive.sh: wrap the append in `{ ...; } 2>/dev/null` so a failed redirection is silent, matching gh-wrapper.sh. - src/deploy/entrypoint.sh: pre-create the log as dev:node 0664 next to the existing hive-metrics setup so appends from both writers land. The directory stays 0755; only this one file is group-writable. - bin/test_git_credential_hive.sh: assert a `get` never emits token-access.jsonl / Permission denied noise. The harness has no /var/run/hive-metrics either, so it reproduces the leak exactly; the assertion fails on the old helper and passes on the new one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CoYvUkv8Gp4AHGWLo97nqb Signed-off-by: Gregory Hunt <greg@on-board.ai>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Scanner review β one finding (Medium)The The token-access audit log becomes truncatable/forgeable by every audited agent UID ( The PR pre-creates Suggested: have the trusted side own the writes (agents emit to a dev-owned FIFO/collector), or at minimum Advisory review by scanner agent (ACMM L5 β hold-gated mode). Not a merge gate. β hive: agent=scanner backend=copilot model=claude-fable-5 |
|
Scanner review β verified, one security tradeoff worth stating on the record. Verified locally (branch Tradeoff to acknowledge: Scanner agent (ACMM L5 β hold-gated mode); advisory review, no merge action. β hive: agent=scanner backend=copilot model=claude-fable-5 |
Summary
git-credential-hive.sh: line 157: /var/run/hive-metrics/token-access.jsonl: Permission deniedinto the agent's pane. The helper appends an audit line with>> "$LOG" 2>/dev/null || true, but2>/dev/nullonly mutes the printf: when the redirection itself fails, the shell reports it on its own stderr before the command runs.gh-wrapper.shhad this exact bug and fixed it with a group wrap in gh wrapper: pr/issue edit fails closed when the injected provenance label is missing; ensure-labels cache is repo-blindΒ #4043; the credential helper never got the same treatment./var/run/hive-metricsis0755 dev:nodeby design (gh wrapper: author-gated list is fail-closed for ALL staff agents β gh api user is 403 for App installation tokens (#3982 regression)Β #4044, protecting the bot-identity file underagent-tokens/) and nothing ever createdtoken-access.jsonl, so no agent UID can open it. Consequence: the audit log that both writers feed, and thatGET /api/token-accessreads, has been empty on every per-UID hive.bin/git-credential-hive.sh: wrap the append in{ ...; } 2>/dev/null || true, matchinggh-wrapper.sh.src/deploy/entrypoint.sh: pre-create the log asdev:nodemode0664next to the existing hive-metrics setup so appends from both writers land. The directory stays0755; only this one file becomes group-writable.Observed on a live standalone hive (2026-09-05): the line appeared on every
gh repo cloneandgit pushfrom the quality agent, and/var/run/hive-metrics/token-access.jsonldid not exist while/api/token-accessreportedno audit log.Related issues
Follows the pattern from #4043; respects the directory mode rationale in #4044.
Testing
bash bin/test_git_credential_hive.shβ 16 passed. The new assertion runs agetand fails iftoken-access.jsonl,Permission denied, orNo such fileappears in the combined output. The harness has no/var/run/hive-metrics, so it reproduces the failing redirection exactly: red on the old helper (15 passed, 1 failed), green on the new one.bash -non both shell files.cd src && go build ./.../go test ./...β not run; no Go changes.mkdir/chown/chmodlines and is|| trueguarded like them.Contributor checklist
v4per CONTRIBUTING.md.git commit -s).changelog.d/fixed-credential-helper-audit-log.mdcarries the changelog entry.π€ Generated with Claude Code
https://claude.ai/code/session_01CoYvUkv8Gp4AHGWLo97nqb